		TITLE	RESNAM - Copyright (C) 1994 SLR Systems

		INCLUDE	MACROS
		INCLUDE	RESSTRUC

if	fg_segm

		PUBLIC	INSTALL_RESOURCE_NAME


		.DATA

		EXTERNDEF	SYMBOL_TEXT:BYTE

		EXTERNDEF	SYMBOL_LENGTH:DWORD,RESNAME_HASH:DWORD,RESOURCE_NAME_OFFSET:DWORD,RESNAME_HASH_TABLE_PTR:DWORD
		EXTERNDEF	FIRST_RESNAME_GINDEX:DWORD,LAST_RESNAME_GINDEX:DWORD

		EXTERNDEF	RESNAME_GARRAY:STD_PTR_S


		.CODE	PASS2_TEXT

		EXTERNDEF	COMMON_INST_INIT:PROC,RESNAME_POOL_GET:PROC


INSTALL_RESOURCE_NAME	PROC
		;
		;EDX IS HASH VALUE, CONVERT IT
		;
		;RETURN EAX GINDEX
		;
		MOV	EAX,EDX
		XOR	EDX,EDX

		PUSH	EBX
		MOV	EBX,RESNAME_HASH_TABLE_PTR

		HASHDIV	RESNAME_HASH		;DX IS HASH VALUE

		PUSHM	EDI,ESI

		MOV	EAX,DPTR [EBX+EDX*4]
		LEA	EBX,[EBX+EDX*4 -RESNAME_STRUCT._RN_NEXT_HASH_GINDEX]
NAME_NEXT:
		TEST	EAX,EAX
		JZ	DO_INSTALL

		MOV	EDX,EAX
		CONVERT	EBX,EAX,RESNAME_GARRAY
		ASSUME	EBX:PTR RESNAME_STRUCT
		;
		;PROBABLE MATCH, NEED COMPARE...
		;
		MOV	ECX,SYMBOL_LENGTH
		MOV	EDI,OFF SYMBOL_TEXT

		SHR	ECX,2				;NOW A UNICODE STRING
		LEA	ESI,[EBX]._RN_UNITEXT

		INC	ECX

		REPE	CMPSD

		MOV	EAX,[EBX]._RN_NEXT_HASH_GINDEX	;GET NEXT POINTER
		JNZ	NAME_NEXT

		POPM	ESI,EDI,EBX
		MOV	EAX,EDX

		RET

DO_INSTALL:
		;
		;DS:BX GETS POINTER...
		;
		MOV	EAX,SYMBOL_LENGTH
		MOV	ESI,EBX

		ADD	EAX,SIZE RESNAME_STRUCT-3		;
		CALL	RESNAME_POOL_GET			;ES:DI IS PHYS, AX LOG

		MOV	EBX,EAX
		MOV	EDX,LAST_RESNAME_GINDEX

		INSTALL_POINTER_GINDEX	RESNAME_GARRAY

		TEST	EDX,EDX
		JZ	FIRST_RESNAME

		MOV	[EDX].RESNAME_STRUCT._RN_NEXT_RN_GINDEX,EAX
FIRST_RESNAME_RET:
		MOV	LAST_RESNAME_GINDEX,EAX

		MOV	[ESI].RESNAME_STRUCT._RN_NEXT_HASH_GINDEX,EAX
		MOV	EDX,EAX

		XOR	ECX,ECX
		MOV	EAX,RESOURCE_NAME_OFFSET

		MOV	[EBX]._RN_NEXT_HASH_GINDEX,ECX	;PTR TO NEXT SAME HASH
		MOV	[EBX]._RN_ALPHA_ORDER,ECX	;ALPHA ORDER INDEX

		MOV	[EBX]._RN_NEXT_RN_GINDEX,ECX

		MOV	ECX,SYMBOL_LENGTH		;LENGTH IN UNICODE BYTES
		MOV	[EBX]._RN_OFFSET,EAX		;OFFSET

		SHR	ECX,1				;ASCII BYTES
		INC	EAX

		MOV	ESI,OFF SYMBOL_TEXT
		ADD	EAX,ECX

		SHR	ECX,1
		MOV	RESOURCE_NAME_OFFSET,EAX

		INC	ECX
		LEA	EDI,[EBX]._RN_UNITEXT

		OPTI_MOVSD

		POPM	ESI,EDI,EBX
		MOV	EAX,EDX

		RET

FIRST_RESNAME:
		MOV	FIRST_RESNAME_GINDEX,EAX
		JMP	FIRST_RESNAME_RET

INSTALL_RESOURCE_NAME	ENDP

endif

		END

